package com.pagepub.core.tag.validator;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class Option extends TagSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = -4602487619075377095L;

	private String display;

	private String beanvalue;

	private String value;

	public String getBeanvalue() {
		return beanvalue;
	}

	public void setBeanvalue(String beanvalue) {
		this.beanvalue = beanvalue;
	}

	public String getDisplay() {
		return display;
	}

	public void setDisplay(String display) {
		this.display = display;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public int doStartTag() throws JspException {
		StringBuffer str = new StringBuffer();
		JspWriter out = this.pageContext.getOut();
		String tempstr = "";
		if (this.beanvalue.equalsIgnoreCase(this.value))
			tempstr = "<option  value=\"" + this.beanvalue
					+ "\" selected=\"true\">" + this.getDisplay() + "</option>";
		else
			tempstr = "<option  value=\"" + this.beanvalue + "\" >"
					+ this.getDisplay() + "</option>";
		str.append(tempstr);
		try {
			out.print(str);
		} catch (IOException e) {
			// TODO 自动生成 catch 块

			e.printStackTrace();
		}

		return 1;
	}

}
